import { App, handleError } from "vue";



export default function (app: App) {
  // 快捷键
  app.directive('shortkey', {
    mounted(el, binding) {
      const value = binding.value;
      const handler = function (event: Event) {
        if (value.prevent) event.preventDefault();
        event && value.handler(event);
      }
      el.__vueShortkey = handler;
      window.addEventListener('keydown', handler)

    },
    unmounted(el) {
      // 移除事件监听器
      el.removeEventListener('keydown', el.__vueShortkey);
    },
  })
}